package logic

import (
	"context"
	"taobao-merchandise/mysql/models"

	"taobao-merchandise/merchandiserpc/internal/svc"
	"taobao-merchandise/merchandiserpc/merchandiserpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type ShopListLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewShopListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ShopListLogic {
	return &ShopListLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 商品列表
func (l *ShopListLogic) ShopList(in *merchandiserpc.ShopListRequest) (*merchandiserpc.ShopListResponse, error) {
	// todo: add your logic here and delete this line

	var shop models.Shop
	var shops []*merchandiserpc.ShopList

	list, err := shop.ShopList(models.DB, shops, in)
	if err != nil {
		return nil, err
	}

	return &merchandiserpc.ShopListResponse{
		List: list,
	}, nil
}
